﻿@using YanForum.Engine.ViewModels
@model PostUpdate

@{
    ViewBag.Title = Model.Id == 0 ? "Thêm mới bài viết" : "Cập nhật bài viết";
    Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
}
@Styles.Render("~/Content/fileUpload")
<link href="/Content/jquery.Jcrop.min.css" rel="stylesheet" />

@using (Html.BeginForm("Update", "Post", new { area = "Admin" }, FormMethod.Post, new { @class = "form-horizontal" }))
{
@*@Html.AntiForgeryToken()
    @Html.ValidationSummary()*@

    if (ViewBag.Success != null)
    {
    <div class="form-group">
        <div class="alert alert-info">
            @ViewBag.Success
        </div>
    </div>
    }
    <div class="form-group">
        @Html.LabelFor(m => m.Title, new { @class = "col-sm-2" })
        <div class="col-sm-10">
            @Html.TextBoxFor(r => r.Title, new { @class = "form-control" })
            @Html.HiddenFor(r => r.Id)
            @Html.ValidationMessageFor(m => m.Title)
        </div>
    </div>
    
    <div class="form-group">
        @Html.LabelFor(m => m.Content, new { @class = "col-sm-2" })
        <div class="col-sm-10">
            <div>
                <span class="btn btn-success fileinput-button">
                    <i class="glyphicon glyphicon-plus"></i>
                    <span>Chọn ảnh cho bài viết</span>
                    <input id="filePostContent" type="file" name="filePostContent">
                </span>
                <!-- The global progress bar -->
                <div id="progressPost" class="progress" style="margin-top: 10px;">
                    <div class="progress-bar progress-bar-success"></div>
                </div>
            </div>
            @Html.TextAreaFor(r => r.Content, new { @class = "form-control editor", cols = 100, rows = 3, id = "editor" })
            @Html.ValidationMessageFor(m => m.Content)
        </div>
    </div>
    
    <div class="form-group">
        <div class="col-sm-2">Thumbnail</div>
        <div class="col-sm-6">
            <span class="btn btn-success fileinput-button">
                <i class="glyphicon glyphicon-plus"></i>
                <span>Chọn file</span>
                <input id="fileupload" type="file" name="fileAvatar">
            </span>
            <!-- The global progress bar -->
            <div id="progress" class="progress" style="margin-top: 10px;">
                <div class="progress-bar progress-bar-success"></div>
            </div>
        </div>
    </div>
    
    <div class="form-group">
        <label class="col-sm-2">&nbsp;</label>
        <div class="col-sm-10">
            <div id="filesUploaded" class="files">
                @if (!string.IsNullOrEmpty(Model.ThumbFolder) && !string.IsNullOrEmpty(Model.ThumbName))
                {
                    <img src="@Model.ThumbFullPath" alt="@Model.Title" class="img img-thumbnail" />
                }
            </div>
            @Html.HiddenFor(r => r.ImagePath)
        </div>
    </div>
    <div class="form-group">
        <div class="col-sm-2">&nbsp;</div>
        <div class="col-sm-6">
            <button type="submit" class="btn btn-default">@(Model.Id == 0 ? "Thêm mới" : "Cập nhật")</button>
        </div>
    </div>
}
@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
    <script src="/Scripts/ckeditor/ckeditor.js"></script>
    <script src="/Scripts/ckeditor/common.editor.js"></script>

    <script src="/Scripts/jquery.Jcrop.min.js"></script>
    @Scripts.Render("~/bundles/fileUpload")
}

